In HyperCard 1.2, “target” refers to a field’s contents. In 1.1 it refers to a card, button or field. In 1.2 you refer to a card, button or field as “the target”. Get it?
Compacting Trick
When you load a stack created pre-1.2, compact it two times in 1.2 for best results.
Undos and Reverts
If you accidentally erase all of a card’s graphics (double clicking the eraser does this), immediately press the tilde (~) or Escape key, or Command/Z. If that fails, try Revert from the Paint menu. Revert takes you back to when you last entered this card, so watch out.
Initializing Variable
To initialize a variable, put the assignment of the variable into an openStack script. Here is an example:
on openStack
global var
if var is empty then put 12 into var
end openStack
This means that no matter how often you go to this stack, the var will only be assigned this value the first time, since the second time into the stack the variable will no longer be empty.
Double Click to the Message Box
You don’t have to mouse to a Message Box that is already open. Command/M two times closes the box and then reopens it with the cursor blinking inside.
And when you are in the message box, the cursor can be anywhere, not just at the end of the typing, to execute the command.
Easy Formatting
Double clicking on the A in the Tools menu (it has to be “torn off” first) brings up the font formatting dialog. You can also go to the formatting dialog during typing, or at any time before you click the mouse elsewhere on the card.
Using Plain English
Did you know that “Not” in HyperTalk is like not in English? For example:
if the variable is not "Yes" then do whatever you want to do
or
on mouseUp
set visible of field "fieldname" to not visible of field "fieldname"
end mouseUp
Finding Misspelled Words
If you spell something wrong in a script, you can find all other occurrences of the error this way:
searchscript "misspelled word", "stackname"
where misspelled word is the error and stackname is the stack to be searched.
Duplicating a Background
Here's a way to re-use a background as a second distinct background in a stack: Copy the card, go to a temporary stack, Paste the card. Copy this card immediately. Go to the original stack and Paste the card. Now you have two identical backgrounds in the stack, not just two cards operating under the same background. You'll probably think of a use for this if you try hard enough.
How Much Space Left?
Type the diskspace into the message box, hit Return, and you get the remaining space on the current drive.
Select and Print
You can print just a part of a script when you are in the script editor. Just highlight the part you want to print and click on Print.
Using the Selection Tool
Command/S shrinks around a selection until there is no surrounding space. If you want a rectangular selection, but no extra space, hold down the Command key while selecting the Selection tool.
For Big Screen Users
This handy script is for Mac II and other big screen users. It sets up HyperCard with the message box, tool palette and pattern palette all open. Put these two scripts in place:
First, under StartUp in the Home stack script, type a line,
setWindow.
Second, type this script at the end of your Home stack script:
on setWindow
answer "Which CPU?" with "Mac II" or "Mac+"
if it is "Mac II" then
show menuBar
show card window at 20,50
show tool window at 524,198
show pattern window at 524,36
show message window at 0,370
else if it is "Mac+" then
show card window at 0,0
hide tool window
hide pattern window
show msg at 30,260
hide msg
end if
end setWindow
You can change the x,y of the various windoids and windows if you like.
Button, Button; Who Has the Button
If you have trouble losing buttons, put this script in your Home Stack script and you'll be warned before deleting a button:
on deleteButton
answer "You are about to delete this button."¬
with "OK" or "Don't do that!"
if it is "Don't do that!" then
doMenu "copy button"
doMenu "paste button"
end if
end deleteButton
Locked fields can act like a button. Once the field is locked, you can place a mouseUp handler into the script of the field so it will do its button thing.
Sorting Fields
Here's a handy field sorter. Let's say you type in a list of names in a field. You want to sort them. Assuming that it is a list of last names only, you can sort them. Or you can sort lines based on the beginning sequence of characters. Here is the script to do it:
on mouseUp
set lockscreen to true -- unless you want to watch it sort
set cursor to 4 -- the wristwatch
put number of words of field 1 into N -- or number of lines
-- replace field 1 with number of field
put 1 into m
repeat while m<N
put 3*m+1 into m
end repeat
repeat while m>1
put m div 3 into m
repeat with j=m+1 to N
get word j of field 1
put (j-m) into i
repeat until i<=0
if it >= word i of field 1 then exit repeat
put word i of field 1 into word (i+m) of¬ field 1
subtract m from i
end repeat
put it into word (i+m) of field 1
end repeat
end repeat
set lockscreen to false -- unless you want to watch it sort
set cursor to 5 -- arrow or browse tool
end mouseUp
The credit for this script goes to Shell, but no first name was given. It appeared in Wheels For The Mind, Vol. 4, No. 2.
Little Lost Button
Didja ever hide a button or field on yourself? Not to worry. This script by Paul Foraker will find it for you. And all the rest of your hidden buttons or fields, too.
-- make a new (temporary) button
on mouseUp
repeat with i=1 to the number of fields
-- or buttons, cards, background buttons, etc.
show field i -- or button, card, etc.
end repeat
end mouseUp
Animating Cursors
Would you like a “cute” animated cursor during certain HyperCard operations? Create the various versions of the cursor. Number these versions consecutively. Now the script — repeatedly call for those numbers, like this:
on MyCursor
repeat with CNum = 128 to 134
-- or whatever numbers you used
set cursor to CNum
end repeat
end MyCursor
Lose Those Curly Quotes
If you use Laser Quotes or some other INIT or cdev to make " and ' into “ or ” and ‘ or ’ none of your HyperCard scripts containing quotation marks will work. Disable the curly quotes while typing scripts in HyperCard.
The Pointy Finger
When you ask HyperCard for “the mouseLoc” you get the location of the middle pixel on the end of the pointing finger of the browse tool.
NASA and the Mac
NASA is now using a HyperCard stack to find images on a DEC MicroVax file server. The images are displayed on a networked Mac II.
Upper or Lower — Doesn’t Matter
Nothing is case sensitive in HyperCard. So all these will work: GO next card, go Next Card, GO NEXT CARD, go next card, or go NeXt CaRd.
New Commands
Some of the new commands available in HyperCard 1.2 include find whole, find string, hide/show card/background/picture, select before/after text, chunk of field/msg box/field, the click v, the click H, the found chunk, the found field, the found line and many others.
Here is a script which is making the rounds for entering FatBits easily:
on mouseUp
-- Zoom Z, C. Davis, 1988 after G. Porter 1988
wait until the mouse is down
choose pencil tool
click at the mouseLoc with CommandKey
wait until the mouse is up
choose browse tool
end mouseUp
If you try it, you will find that once in FatBits, you can’t stay to do any work. Cut the lines above mouseUp which say “wait until the mouse is up” and “choose browse tool” and it works fine. Does anyone know what those extra two lines are supposed to do?
Good Vaporware!
Is vaporware good or bad? Maybe good in this case. There is a HyperCard stack called ΔH(vapor) which studies the vapor pressure of liquids as a function of temperature.
Losing Visual Effects on a II
I lost all my visual effects in HyperCard. Where did they go? If you have a Mac II and are operating in color mode, that’s why they are gone. Use the 2-bit black and white mode. I thought HyperCard 1.2 was doing it, since I got the Mac II and HyperCard 1.2 at the same time. Not true. It’s the color mode which disables visual effects.
Stacking Toggled Buttons
One handy HyperCard trick is to stack two “toggling” buttons on top of each other, so that when one is selected, the other automatically gets top position and is visible. Here’s how. Make two buttons. Name them appropriately (I’m using ButtonOne and ButtonTwo). ButtonOne gets this script:
on mouseUp
hide card button ButtonOne
show card button ButtonTwo
end mouseUp
Script ButtonTwo to hide Two and show One, using the script format above. Put in any other scripting to make the buttons do what you wish. Drag one button on top of the other. Get the browse tool and try it out. To get at the bottom button for any reason, use the message box and type show card button ButtonOne (or ButtonTwo, as needed). Or just get the button tool, select the top button and drag it off to the side, revealing the other button.
Cheapie Protection
Here is a simple, low-level device to keep prying eyes out of your stack. Put it in your stack script:
on OpenStack
ask "Password, please?"
if it is "yourPassword" then
-- put your password where it says "yourPassword"
go to next card -- or whatever you want it to do
else
go home -- or quit HyperCard, or whatever you wish
end if
end OpenStack
This will keep the IBM rabble and non-programmer Mac owners out, but it isn't very sophisticated. Any script reading stack will strip your password out for the world to see.
Your Own Dialog Boxes
Dialog boxes are easy in HyperCard. Try this example, then replace the words in quotes with your own text. Create a button and script it this way:
on mouseUp
answer "What shall I do?" with "Continue" or "quit" or "punt"
-- you cannot have more than three answer choices
end mouseUp
And here is an "ask" script:
on mouseUp
ask "Type Your Name" with "John Q. Public"
if it is "Phil Russell" then
go next card -- or whatever you want done
else
if it is not Alfonso Smith then
go previous card -- or whatever you want done
end if
end if
end mouseUp
Remember, you can substitute your own "Ask" criteria (Type Your Name), your own default (John Q. Public), your own "correct" response (Phil Russell) and your own desired HyperCard actions depending on what is typed into the dialog box. In fact, can you see how to make this Ask statement into a simple password protection for a stack?
Auto-Scripting
Here is a time saver in HyperCard. If you have several lines of script which you would like to use several times without retyping it? To do this, you will create a subroutine in HyperCard, and then call for the subroutine to automatically type the script for you. Here is an example:
on myCommand --your subroutine, in this case named
-- MyCommand, must be without spaces
-- place the script which you want to use repeatedly right here
end myCommand
Now you can imbed this routine in any script. To do that, when you are ready for the script you hid in myCommand, you simply type myCommand, and the script is executed.